<template>
  <ul class="newList list" data-v-472d0f82>
    <li data-v-472d0f82 class="newItem listItem" v-for="(item,index) in list" :key="index" @click="details(index)">
      <div data-v-472d0f82 class="topImg" >
        <img
          data-v-472d0f82
          :src="item.picUrl"
          alt="不锈钢指甲刀"
          class="mainPic"
        />
        <p data-v-472d0f82 class="productName">{{item.title}}</p>
      </div>
      <p data-v-472d0f82 class="priceText">
        <strong data-v-472d0f82>￥{{item.price}}</strong>
        <span data-v-472d0f82 class="largeText">重量：{{item.weight}}</span>
      </p>
    </li>
  </ul>
</template>
<script>
export default {
  props:['id'],//判断参数
  data() {
    return {
      list:[]
    }
  },
  created() {
      let url='/api/productSet/getHotAndNewProduct'
      if(this.id==0){//根据父级传参获取相应数据
          this.$axios.post(url,{type:"0"}).then((res)=>{
            this.list=res.data.data
        })
      }else{
          this.$axios.post(url,{type:"1"}).then((res)=>{
            this.list=res.data.data
        })
      }
  },
  methods: {
    details(index){
      console.log(9)
      var arr = [this.id,index,0];
      console.log(arr)
      this.$router.push({
        path: "/details/"+arr
      });
    }
  },
};
</script>
<style>
</style>